{% extends 'base.html' %}
{% block css %}
<link href="/static/css/dataTables.bootstrap.min.css" rel="stylesheet">
{% endblock %}
{% block content %}
<div class="right_col" role="main">
    <div class="">
        <div class="clearfix"></div>

        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">

                <ul class="nav nav-tabs">
                    <li><a href="{% url 'module_deploy' %}">模块部署</a></li>
                    <li class="active"><a href="{% url 'module_list' %}">模块管理</a></li>
                </ul>

                <div class="x_panel" style="border-top:none;">
                    <div class="x_title">
                        {% if perms.deploy.edit_module %}
                        <a href="{% url 'module_add' %}" style="float:left;" class="btn btn-info btn-sm" role="button"><i class="fa fa-plus"></i></a>
                        {% endif %}
                        <h2>模块管理<small>| 模块部署</small> </h2>
                        <ul class="nav navbar-right panel_toolbox">
                            <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                            </li>
                            <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                            <ul class="dropdown-menu" role="menu">
                                <li><a href="#">Settings 1</a>
                                </li>
                                <li><a href="#">Settings 2</a>
                                </li>
                            </ul>
                            </li>
                            <li><a class="close-link"><i class="fa fa-close"></i></a>
                            </li>
                        </ul>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content">
                        <table id="datatable" class="table table-striped table-bordered">
                            <thead>
                                <tr>
                                    <th>模块名称</th>
                                    <th>调用模块</th>
                                    <th>上传者</th>
                                    <th>备注</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for m in modules %}
                                <tr>
                                    <td>{{ m.name }}</td>
                                    <td>{{ m.module }}</td>
                                    <td>{{ m.user.first_name }}</td>
                                    <td>{{ m.remark }}</td>
                                    <td>
                                    <fieldset {% if not request.user.pk == m.user.pk and not request.user.is_superuser %}disabled{% endif %}>
                                        <a href="{% url 'module_edit' id=m.pk %}" class="btn btn-info btn-xs" {% if not perms.deploy.edit_module %}disabled="disabled"{% endif %}><i class="fa fa-pencil"></i></a>
                                        <a href="#" data-toggle="modal" data-target="#reqDelete-t{{ m.pk }}" class="btn btn-danger btn-xs"
                                           {% if not perms.deploy.edit_module %}disabled="disabled"{% endif %}><i class="fa fa-trash-o"></i></a>
                                    </fieldset>
                                    </td>
                                    <!-- 模态框（Modal） -->
                                    <div class="modal fade" id="reqDelete-t{{ m.pk }}" tabindex="-1" role="dialog" aria-labelledby="reqDelete" aria-hidden="true">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                                    <h4 class="modal-title" id="reqDelete">提示</h4>
                                                </div>
                                                <div class="modal-body">
                                                    确认是否删除？
                                                    <div><br /><strong>{{ m.name }}</strong></div>
                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">关闭</button>
                                                    <a style="margin:4px;" class="btn btn-danger btn-sm" href="{% url 'module_delete' %}?id={{ m.pk }}&delete=1">删除</a>
                                                </div>
                                            </div><!-- /.modal-content -->
                                        </div><!-- /.modal-dialog -->
                                    </div><!-- /.modal -->
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
{% block js %}
<script src="/static/js/jquery.dataTables.min.js"></script>
<script src="/static/js/dataTables.bootstrap.min.js"></script>
<!-- Datatables -->
<script>
    $(document).ready(function() {
            $('#datatable').dataTable();
            $('#datatable1').dataTable();
            });
</script>
<!-- /Datatables -->
{% endblock %}
